package com.hyq.controller;

import com.hyq.model.User;
import com.hyq.service.ManagerService;
import com.hyq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping("/manager")
public class ManagerController {

    @Autowired
    public ManagerService managerService;
    @Autowired
    public UserService userService;


    //管理员登录
    @RequestMapping("/login")
    public String mLogin(User userInfo, HttpServletRequest request) {
        User newM = userService.login(userInfo);
        if (newM != null) {
            request.getSession().setAttribute("ManagerInfo", newM);
            return "operation";
        } else {
            return "index";
        }
    }

    //管理员注销
    @RequestMapping("/logOut")
    public String mlogOut(HttpServletRequest request) {
        request.getSession().removeAttribute("ManagerInfo");
        return "index";
    }




}
